﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TP2
{
    public partial class EditLegalClientForm : Form
    {
        private string inn;
        string title;
        string founders;
        int capital;
        string org_type;
        int id_client;
        LegalClientForm legalFR;
        public EditLegalClientForm(string Title,string INN,string Founders,int Capital,string OrgType,int idClient, LegalClientForm Fr)
        {
            title = Title;
            inn = INN;
            founders = Founders;
            capital = Capital;
            org_type = OrgType;
            id_client = idClient;
            legalFR = Fr;
            InitializeComponent();
        }

        private void EditLegalClientForm_Load(object sender, EventArgs e)
        {
            textBoxTitle.Text = title;
            textBoxCapital.Text = capital.ToString();
            maskedTextBox1.Text = inn;
            textBoxFounder.Text = founders;
            textBoxType.Text = org_type;
        }

        private void buttonClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                title = textBoxTitle.Text;
                inn = maskedTextBox1.Text;
                founders = textBoxFounder.Text;
                capital = Convert.ToInt32(textBoxCapital.Text);
                org_type = textBoxType.Text;
                DBWorkClass dbWork = new DBWorkClass();
                dbWork.UpdateLegalClient(title, inn, founders, capital, org_type, id_client);
                legalFR.refreshTable();
                this.Close();
            }
            catch (FormatException) { MessageBox.Show("ошибка во входных данных"); }
        }
    }
}
